// service 统一出口
import request from './request'

export const api = {
  /**
   * methods: 请求
   * @param url 请求地址
   * @param params 请求参数
   */
  get(url: string, params: object | string = {}, showLoading: boolean = false) {
    const config: any = {
      method: 'get',
      url,
      showLoading,
    }
    if (params) config.params = params
    return request(config)
  },
  post(url: string, params: object | string = {}) {
    const config: any = {
      method: 'post',
      url: url,
    }
    if (params) config.data = params
    return request(config)
  },
  put(url: string, params: object | string = {}) {
    const config: any = {
      method: 'put',
      url: url,
    }
    if (params) config.params = params
    return request(config)
  },
  delete(url: string, params: object | string = {}) {
    const config: any = {
      method: 'delete',
      url: url,
    }
    if (params) config.params = params
    return request(config)
  },
}
